package com.example.chapter03;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import com.example.chapter03.util.DateUtil;

public class ButtonEnableActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button_enable);
        TextView tv_test = findViewById(R.id.tv_test);
        Button open = findViewById(R.id.open);
        Button close = findViewById(R.id.close);
        Button btn = findViewById(R.id.Btn);
        btn.setOnClickListener(view -> {
            String desc = String.format("%s 您点击了按钮：    %s",
                    DateUtil.getNowTime(),((Button) view).getText());
            tv_test.setText(desc);
        });

        open.setOnLongClickListener(view -> {
            btn.setEnabled(true);
            return true;
        });
        close.setOnClickListener(view -> {
            btn.setEnabled(false);
        });

    }
}